package com.jwater.core.manager.worker;

import com.jwater.core.manager.common.model.WorkerInfo;
import com.jwater.core.net.Node;

/**
 * @description: worker上下文
 * @author: jnner
 * @createDate: 2021/2/5
 * @version: 1.0
 */
public class WorkerContextImpl implements WorkerContext {
    protected WorkerNodeImpl workerNode;

    @Override
    public int getWorkerIndex() {
        return workerNode.index;
    }

    @Override
    public WorkerInfo getWorkerInfo() {
        if (workerNode == null) {
            return null;
        }
        return workerNode.workerInfo;
    }

    @Override
    public void setHandler(WorkerHandler handler) {
        if (workerNode != null) {
            workerNode.setHandler(handler);
        }
    }

    @Override
    public Node getNode() {
        return workerNode.node;
    }
}
